package com.example.questionnaire.controller;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

import com.example.questionnaire.dao.AnswererTeamDao;
import com.example.questionnaire.entity.AnswererEntity;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.example.questionnaire.entity.AnswererTeamEntity;
import com.example.questionnaire.service.AnswererTeamService;
import com.example.common.utils.PageUtils;
import com.example.common.utils.R;



/**
 * 
 *
 * @author hsz
 * @email 1416446590@qq.com
 * @date 2022-10-29 11:20:57
 */
@CrossOrigin
@RestController
@RequestMapping("questionnaire/answerergroup")
public class AnswererTeamController {
    @Autowired
    private AnswererTeamService answererTeamService;
    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = answererTeamService.queryPage(params);
        return R.ok().put("data", page);
    }

    /**
     * 查询答者群组下的答者
     */
    @ApiOperation("查询答者群组下的答者")
    @RequestMapping("/answerersinfo")
    public R queryAnswererInTeam(@RequestParam Map<String, Object> params){
        PageUtils page = answererTeamService.queryAnswerersInTeam(params);
        return R.ok().put("data", page);
    }



    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") Integer id){
		AnswererTeamEntity answererTeam = answererTeamService.getById(id);

        return R.ok().put("data", answererTeam);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody AnswererTeamEntity answererTeam){
        answererTeamService.save(answererTeam);
        return R.ok();
    }


    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody AnswererTeamEntity answererTeam){
        answererTeamService.updateById(answererTeam);
        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Integer[] ids){
        answererTeamService.removeByIds(Arrays.asList(ids));
        return R.ok();
    }

}
